
var latitude="",longitude="";



function  shangquans(){
       	$("#shangquanxinxi").html("");
	    $.ajax({
        url:urlcore+"/api/tradeArea/selectList",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					$("#xialakuang").show();
				$.each(data.data,function(y,h){
					var shangquanxinxi='<li onclick="selectshangquan('+h.id+',\''+h.areaName+'\')" id="'+h.id+'" >'+h.areaName+'</li>';
			    $("#shangquanxinxi").append(shangquanxinxi);
					});
				}
			},
			error: function() {
				alert("error");
			}
		});
		//批发市场弹窗
    $(function () {
	    $(".zhiweifabu04 em").click(function () {
	        $("#bg").css({
	            display: "block", height: $(document).height()
	        });
	        var $box = $('.payment_time_mask04');
	        $box.css({
	            display: "block",
	        });
	        $(".zhiweifabu04 i").addClass("up");
	    });
	  
	});
	
}

function selectshangquan(id,name){
	$(".xingbie").html("请选择批发市场");
	$("#shangquanid").val("");
	$("#sqnames").html(name);
	$("#shangquanid").val(id);
	//$("#pfsq span").removeClass('up');  //点击关闭按钮的时候，遮罩层关闭
	        $("#bg,.payment_time_mask04").css("display", "none");
	        $(".zhiweifabu04 em").text($(this).html());
	        $(".zhiweifabu04 i").removeClass("up").addClass("down");
	    //$(".payment_time_mask04 li").on('click',function () {});
}



	
	function leibiefun(id,name){
	$(".leibiefuns").html("请选择主营类别");
	$("#zhuyingleibieid").val("");
	$(".leibiefuns").html(name);
	$("#zhuyingleibieid").val(id);
	//$("#pfsq span").removeClass('up');  //点击关闭按钮的时候，遮罩层关闭
	        $("#bg,.payment_time_mask01").css("display", "none");
	        $(".zhiweifabu01 em").text($(this).html());
	        $(".zhiweifabu01 i").removeClass("up").addClass("down");
	    //$(".payment_time_mask04 li").on('click',function () {});
	}
	
	 function zhuyingleibies(){
       	$("#zhuyingleibie").html("");
	    $.ajax({
        url:urlcore+"/api/sortType/selectList",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				/*	$("#xialakuang").show();*/
				$.each(data.data.list,function(y,h){
					var zhuyingleibie='<li onclick="leibiefun('+h.id+',\''+h.sortName+'\')" id="'+h.id+'" >'+h.sortName+'</li>';
			    $("#zhuyingleibie").append(zhuyingleibie);
					});
				}
			},
			error: function() {
				alert("error");
			}
		});
		//批发市场弹窗
    $(function () {
	    $(".zhiweifabu01 em").click(function () {
	        $("#bg").css({
	            display: "block", height: $(document).height()
	        });
	        var $box = $('.payment_time_mask01');
	        $box.css({
	            display: "block",
	        });
	        $(".zhiweifabu01 i").addClass("up");
	    });
	});
	
	 }
	



function addtijiao(){
	    if($("#checkbox-1-1").get(0).checked){
	   var shangquanid=$("#shangquanid").val();
	    var touxiang=$("#touxiang").val();
	    var fengmian=$("#fengmian").val();
	    var storeName=$("#storeName").val();
	    var userName=$("#userName").val();
	    var phone=$("#phone").val();
	    var cityResult3=$("#cityResult3").html();
	    var spreadcode=$("#spreadcode").val();
	    var zhuyingleibieid=$("#zhuyingleibieid").val();
	     var province="";
       var city="";
       var county="";
	       if(cityResult3!=""){
	       		var imgarr1 = cityResult3.split("-");
	       		$.each(imgarr1, function(index, value) {
                  if(index==0){
                  	 province+=value;
                  }else if(index==1){
                  	city+=value;
                  }else if(index==2){
                  	county+=value;
                  }
	       		});
	       }
	    var addressnumber=$("#addressnumber").val();
	   // var zhuyingleibie=$("#zhuyingleibie").val();
	    var getmin=$("#getmin").val();
	    var packMin=$("#packMin").val();
	    var hunpi=$("#hunpi").val();
	    var baohuan=$("#baohuan").val();
	    var xiangxidizhi=$("#xiangxidizhi").val();
	    var spreadcode=$("#spreadcode").val();
	    
	    if($("#checkbox-1-1").attr("checked")){
	    	   $.ajax({  
        url : urlcore + "/api/shopInfo/adds4",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :  JSON.stringify({
        	  "userId":uuuuid,
              "sellerType":1,
              " headImg ":touxiang,
               "storeImg":fengmian,
               "storeName":storeName,
               "userName":userName,
               "phone":phone,
               "province":province,
               "city":city,
               "county":county,
                "addressNumber":addressnumber,
                 "getMin":getmin,
                  "packMin":packMin,
                 "tradeAreaId":shangquanid, //商圈id
                 "isMix":hunpi,
                 "isChange":baohuan,
                  "spreadCode":spreadcode,
                  "lng":longitude,   //经度
                  "lat":latitude,      //维度*/
                 "address":xiangxidizhi,
                "sortTypeId":zhuyingleibieid /*主营类别*/
        	}),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	if (data.success == true) {
        		   window.location.href="12.0.0buy_wode.html";  
        	}else{
        		alert(data.msg);
        		 //  window.location.href="12.0.0buy_wode.html";  
        	}
         
        },
        error:function(){  
            alert("提交失败");  
        }  
    }); 
	    }else{
	    	alert("入驻协议未同意");
	    }
}else{
	alert("未选中同意开通");
}
	    }







